package com.yiya.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yiya.bean.SerCompany;
import com.yiya.bean.SysUser;
import com.yiya.mapper.SerCompanyMapper;
import com.yiya.model.SerCompanyCplex;
import com.yiya.model.SerCompanyCplexModel;

@Service("serCompanyService")
public class SerCompanyService{
	@Autowired
	private SerCompanyMapper serCompanyMapper;

	public List<SerCompanyCplex> queryByList(SerCompanyCplexModel bean) {
		Integer rowCount = queryByCount(bean);
		bean.getPager().setRowCount(rowCount);
		List<SerCompanyCplex> list = serCompanyMapper.selectByModel(bean);
		return list;
	}

	public int queryByCount(SerCompanyCplexModel bean) {
		return serCompanyMapper.countByModel(bean);
	}
	
	public int add(SerCompany bean){
		return serCompanyMapper.insert(bean);
	}
	
	public int Update(SerCompany bean){
		return serCompanyMapper.updateByPrimaryKeySelective(bean);
	}
	
	public SerCompany queryById(Integer id){
		return serCompanyMapper.selectByPrimaryKey(id);
	}
	
	public void delete(Integer[] ids,SysUser user){
		for(Integer id:ids){
			Date nowTime = new Date();
			SerCompany bean = serCompanyMapper.selectByPrimaryKey(id);
			bean.setUpdateBy(user.getId());
			bean.setUpdateTime(nowTime);
			bean.setDelFlag(1);
			serCompanyMapper.updateByPrimaryKeySelective(bean);
		}
	}
	
	/**
	 * 获取维修公司、无分页
	 * @param bean
	 * @return
	 */
	public List<SerCompanyCplex> getSerCompanyList(SerCompanyCplexModel bean){
		return serCompanyMapper.selectSerCompany(bean);
	}
	
	
}
